package com.sdf.com.mvp_rx_retraft.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environment;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.sdf.com.mvp_rx_retraft.MyApplication;
import com.sdf.com.mvp_rx_retraft.R;

import java.io.File;

/**
 * Created by feq on 2016/11/17.
 */

public class GlideUtis {
    public static void setImg(String imgUrl, ImageView view) {
        Glide.with(MyApplication.getContext()).
                load(imgUrl).
//                placeholder(R.mipmap.loading).
        into(view);
    }

    public static void downImg(final Context context, final String imgUrl, final int type) {
        Glide.with(MyApplication.getContext()).load(imgUrl)
                .asBitmap()
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
//                        if (type == Constants.SAVE_YTPE) {
//                            BitmapUtil.saveBitmap(bitmap, Environment.getExternalStorageDirectory()
//                                    + File.separator + "shendou", Md5Utils.md5(imgUrl) + ".jpg", true);
//                        } else {
//                            ShareUtils.shareGirl(bitmap, context);
//                        }
////                        return bitmap
                    }
                });
    }

}
